var vm = new Vue({
	el:'#loginform',
	data:{
		username:'',
		password:'',
		captcha:'',
		error:'',
		errorMsg:'',
		src:'login/captcha.jpg'
	},
	beforeCreate:function(){
		if(self != top){
			top.location.href = self.location.href;
		}
	},
	methods:{
		refreshCode:function(){
			this.src = "login/captcha.jpg?t="+$.now();
		},
		login:function (event){
			var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
			$.ajax({
				type:"POST",
				url:"login/login",
				data:data,
				dataType:"json",
				success:function(result){
					if(result.status == 200){
						parent.location.href='index.html';
					}else{
						vm.error=true;
						vm.errorMsg = result.msg;
						vm.refreshCode();
					}
				}
			})
			
		}
		
		
		
	}
	
})